package net.qunzhi.modules.job.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.qunzhi.common.utils.PageUtils;
import net.qunzhi.common.utils.Query;
import net.qunzhi.modules.job.dao.ScheduleJobLogDao;
import net.qunzhi.modules.job.entity.ScheduleJobLogEntity;
import net.qunzhi.modules.job.query.ScheduleJobLogQuery;
import net.qunzhi.modules.job.service.ScheduleJobLogService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

@Service("scheduleJobLogService")
public class ScheduleJobLogServiceImpl extends ServiceImpl<ScheduleJobLogDao, ScheduleJobLogEntity> implements ScheduleJobLogService {

    @Override
    public PageUtils queryPage(ScheduleJobLogQuery queryForm) {
        String jobId = queryForm.getJobId();

        IPage<ScheduleJobLogEntity> page = this.page(
                new Query<ScheduleJobLogEntity>().getPage(queryForm),
                new QueryWrapper<ScheduleJobLogEntity>().like(StringUtils.isNotBlank(jobId), "job_id", jobId)
        );

        return new PageUtils(page);
    }

}
